package com.ruoyi.web.controller.maple;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.maple.domain.GameBaseInfo;
import com.ruoyi.maple.service.IGameBaseInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 游戏基础信息Controller
 * 
 * @author maple
 * @date 2025-05-08
 */
@RestController
@RequestMapping("/maple/gameBaseInfo")
public class GameBaseInfoController extends BaseController
{
    @Autowired
    private IGameBaseInfoService gameBaseInfoService;

    /**
     * 查询游戏基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('maple:gameBaseInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameBaseInfo gameBaseInfo)
    {
        startPage();
        List<GameBaseInfo> list = gameBaseInfoService.selectGameBaseInfoList(gameBaseInfo);
        return getDataTable(list);
    }

    /**
     * 导出游戏基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('maple:gameBaseInfo:export')")
    @Log(title = "游戏基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameBaseInfo gameBaseInfo)
    {
        List<GameBaseInfo> list = gameBaseInfoService.selectGameBaseInfoList(gameBaseInfo);
        ExcelUtil<GameBaseInfo> util = new ExcelUtil<GameBaseInfo>(GameBaseInfo.class);
        util.exportExcel(response, list, "游戏基础信息数据");
    }

    /**
     * 获取游戏基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('maple:gameBaseInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gameBaseInfoService.selectGameBaseInfoById(id));
    }

    /**
     * 新增游戏基础信息
     */
    @PreAuthorize("@ss.hasPermi('maple:gameBaseInfo:add')")
    @Log(title = "游戏基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameBaseInfo gameBaseInfo)
    {
        gameBaseInfo.setCreateBy(getUsername());
        return toAjax(gameBaseInfoService.insertGameBaseInfo(gameBaseInfo));
    }

    /**
     * 修改游戏基础信息
     */
    @PreAuthorize("@ss.hasPermi('maple:gameBaseInfo:edit')")
    @Log(title = "游戏基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameBaseInfo gameBaseInfo)
    {
        gameBaseInfo.setUpdateBy(getUsername());
        return toAjax(gameBaseInfoService.updateGameBaseInfo(gameBaseInfo));
    }

    /**
     * 删除游戏基础信息
     */
    @PreAuthorize("@ss.hasPermi('maple:gameBaseInfo:remove')")
    @Log(title = "游戏基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gameBaseInfoService.deleteGameBaseInfoByIds(ids));
    }
}
